package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OwnerRoomRecord;
import com.ruoyi.system.service.IOwnerRoomRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房屋绑定记录 Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@DataSource(DataSourceType.ZY)
@RestController
@RequestMapping("/system/record")
public class OwnerRoomRecordController extends BaseController
{
    @Autowired
    private IOwnerRoomRecordService ownerRoomRecordService;

    /**
     * 查询房屋绑定记录 列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(OwnerRoomRecord ownerRoomRecord)
    {
        startPage();
        List<OwnerRoomRecord> list = ownerRoomRecordService.selectOwnerRoomRecordList(ownerRoomRecord);
        return getDataTable(list);
    }

    /**
     * 导出房屋绑定记录 列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OwnerRoomRecord ownerRoomRecord)
    {
        List<OwnerRoomRecord> list = ownerRoomRecordService.selectOwnerRoomRecordList(ownerRoomRecord);
        ExcelUtil<OwnerRoomRecord> util = new ExcelUtil<OwnerRoomRecord>(OwnerRoomRecord.class);
        util.exportExcel(response, list, "房屋绑定记录 数据");
    }

    /**
     * 获取房屋绑定记录 详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(ownerRoomRecordService.selectOwnerRoomRecordByRecordId(recordId));
    }

    /**
     * 新增房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OwnerRoomRecord ownerRoomRecord)
    {
        return toAjax(ownerRoomRecordService.insertOwnerRoomRecord(ownerRoomRecord));
    }

    /**
     * 修改房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OwnerRoomRecord ownerRoomRecord)
    {
        return toAjax(ownerRoomRecordService.updateOwnerRoomRecord(ownerRoomRecord));
    }

    /**
     * 删除房屋绑定记录 
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "房屋绑定记录 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(ownerRoomRecordService.deleteOwnerRoomRecordByRecordIds(recordIds));
    }
}
